#coding=utf-8
import json
import sys
import os
from pydub import AudioSegment
res_path=os.getcwd()

def mp3TpWav(path):
	outPath=os.path.join(res_path,"out")
	index0=path.rfind('\\')
	index1=path.rfind('.')
	name=path[index0+1:index1]

	outPath=os.path.join(outPath,name+".wav")

	sound = AudioSegment.from_mp3(path)
	sound.export(outPath, format='wav')
	print(outPath+" success------")

def getPngFile():
	path=os.path.join(res_path,"res")
	list = os.listdir(path)
	for dir in list:
		dir_path=os.path.join(path,dir)   # 遍历的全路径
		if(os.path.isfile(dir_path)):   #如果是文件存储
			index=dir_path.rfind(".")
			suffix=dir_path[index+1:]
			if suffix=="mp3" or suffix=="MP3":
				mp3TpWav(dir_path)

if __name__=="__main__":
	getPngFile()
				



